using UnityEngine;
using System.Collections;

public class GameController : MonoBehaviour 
{

	public LeafController leafPrefab;
	public LeafController[] leafs;
	public int N;
	
	private Vector3 explosionPos;
	private float yAngle;
	
	void Start() 
	{
		Physics.gravity = new Vector3(0.0f, 0.0f, -0.5f);
		leafs = new LeafController[N];

		for(int i = 0; i < N; i++)
		{
			leafs[i] = GameObject.Instantiate(leafPrefab) as LeafController;
			leafs[i].transform.Translate(Random.Range(0.0f, 10.0f), 0.0f, Random.Range(0.0f, 10.0f));
			yAngle = Random.Range(0.0f, 360.0f);
			leafs[i].transform.Rotate(0.0f, yAngle, 0.0f);
		}
		
	}
	
	
	void Update() 
	{
		if(Input.GetKey(KeyCode.R))
			Application.LoadLevel(Application.loadedLevel);
		
		if(Input.GetMouseButtonDown(0))
		{
			explosionPos = Camera.mainCamera.ScreenToWorldPoint(Input.mousePosition);
			explosionPos.y = 0;
						
			//leaf.AddExplosionForce(10, explosionPos, 10);
		}
	}

		
}
	